<?php 
//引进配置信息
include '../include/init.php';
//引入数据库配置信息
include '../include/mysql.config.php';
//引入公共函数
include '../include/common.fun.php';


if ($_POST) {
	$username=$_POST['username'];
	$password=md5($_POST['password']);
	$code=strtoupper($_POST['code']);
	session_start();
	if ($code!=$_SESSION['code']) {
		alert('验证码错误');exit;
	}
	$sql="SELECT * from wd_admin where admin_name='{$username}' and admin_password='{$password}'";
	$admin=$db->getOne($sql);
	$adminId=$admin['admin_id'];
	if ($admin) {	
		$_SESSION['admin_login']=1;
		$_SESSION['admin_id']=$adminId;
		$_SESSION['admin_name']=$admin['admin_name'];
		if ($admin['admin_status']!=1) {
			alert('用户限制登录');exit;
		}else{
			alert('登入成功','index.php');exit;
		}
	}else{
		alert('用户名或密码错误');exit;
	}
}



include 'view/login.php';